﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RoleInfoForm.aspx.cs" Inherits="FX.CC.Andon.WebSite.SystemManage.RoleInfoForm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>添加/修改角色</title>
    <script src="../lib/boot.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" method="post">
    <input name="RoleID" class="mini-hidden" />
    <div style="padding-left: 11px; padding-bottom: 5px;">
        <table style="table-layout: fixed;">
            <tr>
                <td style="width: 70px;" align="right">
                    角色名称：
                </td>
                <td style="width: 350px;">
                    <input name="RoleName" emptytext="请输入角色名称" style="width: 350px;" class="mini-textbox"
                        required="true" />
                </td>
            </tr>
            <tr>
                <td style="width: 140px;" align="right">
                    触发及解除异常权限：
                </td>
                <td style="width: 350px;">
                    <select name="OpRight" class="mini-radiobuttonlist">
                        <option value="0">不允许</option>
                        <option value="1">允许（指定产线）</option>
                        <option value="2">允许（所有产线）</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td style="width: 140px;" align="right">
                    签到处理权限：
                </td>
                <td style="width: 350px;">
                    <select name="SignRight" class="mini-radiobuttonlist">
                        <option value="0">不允许</option>
                        <option value="1">允许</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td style="width: 140px;" align="right">
                    修正异常权限：
                </td>
                <td style="width: 350px;">
                    <select name="FixRight" class="mini-radiobuttonlist">
                        <option value="0">不允许</option>
                        <option value="1">允许</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td style="width: 70px;" align="right">
                    描述：
                </td>
                <td style="width: 350px;">
                    <input name="Remark" class="mini-textarea" style="width: 350px; height: 100px;" />
                </td>
            </tr>
        </table>
    </div>
    <div style="text-align: center; padding: 10px;">
        <a class="mini-button" iconcls="icon-save" onclick="onOk" style="width: 60px; margin-right: 20px;">
            保存</a> <a class="mini-button" iconcls="icon-cancel" onclick="onCancel" style="width: 60px;">
                取消</a>
    </div>
    <script type="text/javascript">
        mini.parse();

        var form = new mini.Form("form1");
        var action;
        function onOk(e) {
            SaveData();
        }
        function CloseWindow(action) {
            if (action == "close" && form.isChanged()) {
                if (confirm("数据被修改了，是否先保存？")) {
                    return false;
                }
            }
            if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
            else window.close();
        }

        function SetData(data) {
            if (data.action == "edit") {
                //跨页面传递的数据对象，克隆后才可以安全使用
                data = mini.clone(data);
                action = data.action;
                $.ajax({
                    url: "../service/SystemManageHandler.ashx?action=GetRoleInfo&RoleID=" + data.RoleID,
                    cache: false,
                    success: function (text) {
                        var o = mini.decode(text);
                        form.setData(o);
                        form.setChanged(false);
                    }
                });
            }
            else {
                mini.getbyName("OpRight").setValue("1");
                mini.getbyName("SignRight").setValue("1");
                mini.getbyName("FixRight").setValue("1");
            }
        }

        function SaveData() {
            var o = form.getData();
            var json = mini.encode([o]);
            form.validate();
            if (form.isValid() == false) return;
            if (action == "edit") {
                $.ajax({
                    url: "../Service/SystemManageHandler.ashx?action=ModifyRole",
                    data: { data: json },
                    type: 'POST',
                    success: function (text) {
                        CloseWindow("save");
                    },
                    error: function (jqXHR, textStatus, errorThrown) {
                        alert(jqXHR.responseText);
                    }
                });
            }
            else {
                $.ajax({
                    url: "../Service/SystemManageHandler.ashx?action=AddRole",
                    data: { data: json },
                    type: 'POST',
                    success: function (text) {
                        CloseWindow("save");
                    },
                    error: function (jqXHR, textStatus, errorThrown) {
                        alert(jqXHR.responseText);
                    }
                });
            }

        }
        function GetData() {
            var o = form.getData();
            return o;
        }
        function onCancel(e) {
            CloseWindow("cancel");
        }
    </script>
    </form>
</body>
</html>
